<?php

//发布处理 , 请输出发布后在数据库中的id:$topicid
function do_post($groupid,$post){
        global $db,$TS_USER;
        $title = trim($post['title']);
		$content = trim($post['content']);
		if ($title == '') {
			$title='分享歌曲'.$post['post']['title'];
		} 
		if ($content == '') {
			$content='这是'.$post['post']['geshou'].'演唱的'.$post['post']['geming'];
		} if (mb_strlen($title, 'utf8') > 64 || mb_strlen($title, 'utf8')<5) { 
				$title='我给大家分享'.$post['post']['geshou'].'演唱的'.$post['post']['geming'];
		} if (mb_strlen($content, 'utf8') > 20000) { 
				$content='这是'.$post['post']['geshou'].'演唱的'.$post['post']['geming'];
		}
			$uptime = time();
            $m=implode(',',$post['post']);
			$content=$content.','.$m;
			//聚合
			if($post['juhe']=='1'){
			  $content=$content.',juhe';
			}
			$arrData = array('groupid' => $groupid,
				'typeid' => intval($post['typeid']),
				'userid' => intval($TS_USER['user']['userid']),
				'title' => $title,
				'content' => $content,
				'iscomment' => intval($post['iscomment']),
				'addtime' => time(),
				'uptime' => time(),
				'thread_type'=>$post['thread_select'],
				);
           
			$topicid = $db -> insertArr($arrData, dbprefix . 'group_topics');
            return $topicid;
		
}
